//
//  SeleDevTypeViewController.m
//  AILock
//
//  Created by 谭亚明 on 2020/6/18.
//  Copyright © 2020 tym. All rights reserved.
//

#import "SeleDevTypeViewController.h"
#import "TYMBaseTableView.h"
#import "Sizes.h"
#import "OperationView.h"
#import "InputWifiViewController.h"
#import "SeleDevTypeCell.h"

@interface SeleDevTypeViewController ()<UITableViewDelegate,UITableViewDataSource>

@property(nonatomic,weak) TYMBaseTableView *seleTableView;

@end

@implementation SeleDevTypeViewController

- (void)viewDidLoad {
    [super viewDidLoad];
    [self addBackBtnFunc];
    [self addTitle:@"选择门锁类型"];
    [self initTableView];
}

-(void)initTableView{
    
    TYMBaseTableView *table = [[TYMBaseTableView alloc] initWithFrame:CGRectMake(0,0 , ScreenWidth, ScreenHeight - NavigateonHeight - SafeBottomMargin)];
    table.separatorInset =UIEdgeInsetsMake(5,0,0, 0);
    table.delegate = self;
    table.dataSource = self;
    [self.view addSubview:table];
    [table registerNib:[UINib nibWithNibName:NSStringFromClass([SeleDevTypeCell  class]) bundle:nil] forCellReuseIdentifier:[SeleDevTypeCell identifier]];
    self.seleTableView = table;
}

#pragma  mark - tableView 代理
- (CGFloat)tableView:(UITableView *)tableView heightForRowAtIndexPath:(NSIndexPath *)indexPath{
    return [SeleDevTypeCell cellForHeight];
}

- (NSInteger)tableView:(UITableView *)tableView numberOfRowsInSection:(NSInteger)section{
    return 1;
}

- (UITableViewCell *)tableView:(UITableView *)tableView cellForRowAtIndexPath:(NSIndexPath *)indexPath{
    SeleDevTypeCell *cell = [tableView dequeueReusableCellWithIdentifier:[SeleDevTypeCell identifier] forIndexPath:indexPath];
    
    if (indexPath.row == 0) {
        cell.titlLab.text = @"WiFi/蓝牙指纹锁(无网关)";
    }else if(indexPath.row == 1){
        cell.titlLab.text = @"物联网指纹锁(带网关)";
        cell.stackView.arrangedSubviews.firstObject.hidden = YES;
        cell.stackView.arrangedSubviews[1].hidden = YES;
    }
    return cell;
}

-(void)tableView:(UITableView *)tableView didSelectRowAtIndexPath:(NSIndexPath *)indexPath{
     [tableView deselectRowAtIndexPath:indexPath animated:YES];
    
    NSArray *array = @[@"SmartConfig配网",@"AP配网"];
    OperationView *pop = [[OperationView alloc]initWithFrame:self.view.frame];
    pop.data = array;
    pop.blockCallBackIndex = ^(NSInteger index) {
       
        InputWifiViewController *inputVC = [[InputWifiViewController alloc] init];
        self.equmenModel.peiwangType = index;
        inputVC.equipModel = self.equmenModel;
        [self.navigationController pushViewController:inputVC animated:YES];
    };
    [pop viewShow];
    
    
    if (indexPath.row == 0) {
        
    }
}
@end
